<?php

$file_name = $argv[1];
//读取域名文件
$yuming_arr = file(dirname(__FILE__).'/'.$file_name);

foreach($yuming_arr as $ym){
  $ym_arr = preg_split('/,/',$ym);
  //print_r($ym_arr);

  //die;

  $zone_txt = "zone \"".$ym_arr[0]."\" { type master; file \"".$ym_arr[0].".hosts\"; };\n";

  file_put_contents('./my.zones',$zone_txt,FILE_APPEND);
  
  $hosts_txt = "\$TTL 600\n";
  $hosts_txt .= "@ IN SOA ns1.256sun.com. root.ns1.256sun.com. (\n";
  $hosts_txt .= "                        1997022700 ; Serial\n";
  $hosts_txt .= "                        28800 ; Refresh \n";
  $hosts_txt .= "                        14400 ; Retry \n";
  $hosts_txt .= "                        3600000 ; Expire \n";
  $hosts_txt .= "                        86400 ); Minimum \n";
  $hosts_txt .= "   IN NS  ns1.256sun.com.\n";
  $hosts_txt .= "@  IN A  ".$ym_arr[1];
  $hosts_txt .= "*  IN A  ".$ym_arr[1]."\n";

  $hosts_file = "./hosts/".$ym_arr[0].".hosts";
  file_put_contents($hosts_file,$hosts_txt);

  echo "域名".$ym_arr[0]."生成完毕\n";
}




